package com.spring04.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

import com.spring04.dao.DepartmentDao;
import com.spring04.vo.Department;

public class DepartmentDaoImpl extends JdbcDaoSupport implements DepartmentDao, RowMapper {

	@Override
	public List<Department> findAll() {
		String sql="select * from department";
		List<Department> list=super.getJdbcTemplate().query(sql,this);
		return list;
	}

	@Override
	public Object mapRow(ResultSet rs, int arg1) throws SQLException {
		Department dep=new Department();
		dep.setDeptID(rs.getInt("deptID"));
		dep.setDeptName(rs.getString("deptName"));
		dep.setDeptFunction(rs.getString("deptFunction"));
		return dep;
	}

}
